# $Id$
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=tk
pkgver=8.6.7
pkgrel=2
pkgdesc="A windowing toolkit for use with tcl"
arch=('i686' 'x86_64')
url="http://tcl.sourceforge.net/"
license=('custom')
depends=("tcl=${pkgver}" 'libxss' 'libxft')
options=('staticlibs')
source=(http://downloads.sourceforge.net/sourceforge/tcl/tk${pkgver}-src.tar.gz)
sha1sums=('eb58b4523f376fdf8b1f4439a958227ada52e2c8')

build() {
  cd tk${pkgver}/unix
  [[ $CARCH == "x86_64" ]] && BIT="--enable-64bit"
  ./configure --prefix=/usr --mandir=/usr/share/man --enable-threads --disable-rpath $BIT
  make
}

check() {
  cd tk${pkgver}/unix
#  make test
}

package() {
  cd tk${pkgver}/unix
  make INSTALL_ROOT="${pkgdir}" install install-private-headers
  ln -sf wish${pkgver%.*} "${pkgdir}/usr/bin/wish"
  ln -sf libtk${pkgver%.*}.so "${pkgdir}/usr/lib/libtk.so"
  install -Dm644 license.terms "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # install private headers (FS#14388, FS#47616)
  cd ..
  for dir in compat generic generic/ttk unix; do
    install -dm755 ${pkgdir}/usr/include/tk-private/$dir
    install -m644 -t ${pkgdir}/usr/include/tk-private/$dir $dir/*.h
  done

  # remove buildroot traces
  sed -e "s#${srcdir}/tk${pkgver}/unix#/usr/lib#" \
      -e "s#${srcdir}/tk${pkgver}#/usr/include#" \
      -i "${pkgdir}/usr/lib/tkConfig.sh"
}
